class Solution {//leetcode98——验证二叉搜索树
public:
    bool isValidBST(TreeNode* root) {
        if(root==nullptr) return true;

        bool left=isValidBST(root->left);

        if(root->val>prev) prev=root->val;
        else return false;

        bool right=isValidBST(root->right);

        return left&&right;
    }
private:
    long prev=LONG_MIN;
};